# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     LoginObj.py
   Description :
   Author :        ZhangYiLin
   date：          2020/12/08 10:59
-------------------------------------------------
   Change Activity:
                   2020/12/08 10:59
-------------------------------------------------
"""
from common.NewLoguru import global_log
from common.DriverObj import *

from TestCase.TestLogin.loginPage import LoginPage
from TestCase.TestWelcome.welcome import Welcome

from .TestAccountNumber import TestData
test_account = TestData.Account

# @pytest.fixture(params='class')
# def open_driver():
#     driver = webdriver.Chrome()
#     driver.maximize_window()
#     return driver


# @pytest.fixture(params='class')
# def login(open_driver, username, password):
#     driver = open_driver
#     url = driver.current_url
#     login = LoginPage(driver)
#     login.login(username, password)
#     return url, login


@pytest.fixture(scope='class')
def init_pg(driver):
    login_page = LoginPage(driver)
    welcome_page = Welcome(driver)
    yield driver, login_page, welcome_page


@pytest.fixture(scope='class')
def login(init_pg):
    driver = init_pg[0]
    login_page = init_pg[1]
    login_page.login(test_account['username'], test_account['password'])
    yield driver, login_page
    login_page.return_default_frame()


@pytest.fixture(scope='function')
def open_url(init_pg):
    driver = init_pg[0]
    login_page = init_pg[1]
    yield login_page
    driver.delete_all_cookies()
